//
//  EnterTableViewTwoCell.m
//  ToWhere
//
//  Created by dllo on 15/11/20.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "EnterTableViewTwoCell.h"

@interface EnterTableViewTwoCell()

@property(nonatomic, retain) UILabel *decribeLabel;

@end

@implementation EnterTableViewTwoCell

- (void)dealloc
{
    [_decribe release];
    [_decribeLabel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.decribeLabel = [[UILabel alloc]init];
        self.decribeLabel.textColor = [UIColor colorWithWhite:0.322 alpha:1.000];
        self.decribeLabel.font = [UIFont systemFontOfSize:15 * kWidth];
        self.decribeLabel.numberOfLines = 0;
        [self.contentView addSubview:self.decribeLabel];
        [_decribeLabel release];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat height = [EnterTableViewTwoCell heightOfLabel:self.decribeLabel.text andTextFont:[UIFont systemFontOfSize:15] andTextWidth: self.frame.size.width - 20 * kWidth];
    self.decribeLabel.frame = CGRectMake(10 * kWidth, 10 * kHeight, self.frame.size.width - 20 * kWidth,  height);
}

-(void)setDecribe:(NSString *)decribe
{
    if (_decribe != decribe) {
        [_decribe release];
        _decribe = [decribe copy];
    }
    self.decribeLabel.text = decribe;
}

//自适应高度
+(CGFloat)heightOfLabel:(NSString *)text andTextFont:(UIFont *)font andTextWidth:(CGFloat)width
{
    CGSize size = CGSizeMake(width, MAXFLOAT);
    NSDictionary *dictionary = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:17] forKey:NSFontAttributeName];
    CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dictionary context:nil];
    return frame.size.height;
}

@end
